<?php if(count($this->list) == 0) { ?>
	<?php $request = system_controller_front::getInstance()->getRequest();?>
	<div class="nocomment">
		<i></i>
		<div class="message">
			<?php echo $this->language('暂时还没有评论');?>!<br/>
			<em class="yellow"><?php echo $this->language('点击表单即可发表评论');?> ..</em>
		</div>
		<div class="clear"></div>
	</div>
<?php } else { ?>
<?php
if(!function_exists('formatMessage')) {
	function formatMessage($message) {
		$message = preg_replace('/^[\r\n]+(.*)/is', '$1', $message);
		return preg_replace('/[\r\n]+/is', '<br/>', $message);
	}
}
$avatarDisplay = new resource_display(null, 'avatar');
$_avatar = $avatarDisplay->getThumb(false);
$_author = (string) $this->language('网友');
foreach($this->list AS $row) {
	$pid = $row->getPassportId();
	$reply = isset($this->reply[$row->getId()]) ? $this->reply[$row->getId()] : array();
	$avatar = isset($this->user[$pid]) ? $this->user[$pid]->getAvatar()->getThumb(false) : $_avatar;
	$author = isset($this->user[$pid]) ? $this->user[$pid]->getNickname() : $_author;
?>
<dl onmouseover="this.className='o7';" onmouseout="this.className='';">
	<dt><img src="<?php echo $avatar;?>" /></dt>
	<dd>
		<div class="commentMain">
			<div class="name"><h5><a><?php echo $this->escape($author);?></a></h5></div>
			<div class="content">
				<p id="comment-message-<?php echo $row->getId();?>">
				<?php echo formatMessage($this->escape($row->getMessage()));?>
				</p>
				<?php
				foreach($reply AS $key => $re) {
					$pid = $re->getPassportId();
					$reAvatar = isset($this->user[$pid]) ? $this->user[$pid]->getAvatar()->getThumb(false) : $_avatar;
					$reAuthor = isset($this->user[$pid]) ? $this->user[$pid]->getNickname() : $_author;
				?>
				<dl>
					<dt><img src="<?php echo $reAvatar;?>" /></dt>
					<dd>
						<div class="commentMain">
							<div class="name">
								<h5><a><?php echo $this->escape($reAuthor);?></a></h5>
							</div>
							<div class="content"><?php echo formatMessage($this->escape($re->getMessage()));?></div>
							<div class="bar">
								<a href="#like" onclick="return comment.like(<?php echo $re->getId();?>);"><?php echo $this->language('赞')?>(<span id="like-<?php echo $re->getId();?>" class="number"><?php echo $re->getLike();?></span>)</a>
								<?php echo $this->language('发表于')?>: <em><?php echo $this->date($re->getCreationtime());?></em>
							</div>
						</div>
					</dd>
				</dl>
				<?php } ?>
				<?php if(!empty($reply)) {echo '<div class="clear"></div>';}?>
			</div>
			<div class="bar">
				<a href="#like" onclick="return comment.like(<?php echo $row->getId();?>);"><?php echo $this->language('赞')?>(<span id="like-<?php echo $row->getId();?>" class="number"><?php echo $row->getLike();?></span>)</a>
				<a href="#reply" onclick="return comment.reply(<?php echo $row->getId();?>);"><?php echo $this->language('回复')?></a>
				<?php echo $this->language('发表于')?>: <em><?php echo $this->date($row->getCreationtime());?></em>
			</div>
		</div>
	</dd>
</dl>
<?php } ?>
<div class="clear"></div>
<?php
	$previous = $this->page - 1;
	$next = $this->page + 1;
	$page = $this->paginator($this->list)->render();
	$page = preg_replace('#<a href="[^"]+">([\d]+)</a>#isU', '<a href="#$1" onclick="return comment.load($1);">$1</a>', $page);
	$page = preg_replace('#<a class="previous" href="[^"]+">([^<]+)</a>#isU', '<a href="#' . $previous . '" onclick="return comment.load(' . $previous . ');">$1</a>', $page);
	$page = preg_replace('#<a class="next" href="[^"]+">([^<]+)</a>#isU', '<a href="#' . $next . '" onclick="return comment.load(' . $next . ');">$1</a>', $page);
	echo $page;
}
?>
